package common

import (
	"go-mp-starter/app/common/request"
	"go-mp-starter/app/common/response"
	"go-mp-starter/app/services"

	"github.com/gin-gonic/gin"
)

// ImageUpload 上传图片接口
func ImageUpload(ctx *gin.Context) {
	var form request.ImageUpload
	if err := ctx.ShouldBind(&form); err != nil {
		response.ValidateFail(ctx, request.GetErrorMsg(form, err))
		return
	}
	res, err := services.MediaService.SaveImage(form)
	if err != nil {
		response.BusinessFail(ctx, err.Error())
		return
	}
	response.Success(ctx, res)
}
